package com.ourteam.product.model.api;

import org.apache.commons.lang3.StringUtils;

import com.ourteam.frame.web.AbstractSearchModel;
import com.ourteam.product.model.dao.ProductDatabaseDAOQueryBean;
import com.ourteam.product.model.domain.ProductDatabaseBean;

public class ProductDatabaseSearchModel extends AbstractSearchModel<ProductDatabaseDAOQueryBean> {

	private String databaseName;

	public String getDatabaseName() {
		return databaseName;
	}

	public void setDatabaseName(String databaseName) {
		this.databaseName = databaseName;
	}

	@Override
	public String getMappedDAOField(String aProperty) {

		return ProductDatabaseBean.getMappedDAOField(aProperty);
	}

	@Override
	protected void doBuildQueryBean(ProductDatabaseDAOQueryBean queryBean) throws Exception {

		ProductDatabaseDAOQueryBean.Criteria criteria = queryBean.createCriteria();

		if (StringUtils.isNotBlank(databaseName)) {
			criteria.andDatabaseNameLike(databaseName);
		}

	}

}
